package pl.accuratus.exmore.client.spi;

import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;

public class AbstractExtensionRegistry implements ExtensionRegistry {
	private final Map<Class<? extends Annotation>, ExtensionPoint<?>> extensionPoints = new HashMap<Class<? extends Annotation>, ExtensionPoint<?>>();

	@SuppressWarnings("unchecked")
	@Override
	public <T extends Annotation> ExtensionPoint<T> getExtensionPoint(Class<T> extensionType) {
		return (ExtensionPoint<T>) extensionPoints.get(extensionType);
	}

	@Override
	public void registerExtensionPoint(Class<? extends Annotation> extensionType, ExtensionPoint<?> extensionPoint) {
		if(extensionPoint==null)
			return;
		extensionPoints.put(extensionType, extensionPoint);
	}
}
